<?php
namespace app\admin\http;
use app\admin\model\auth\MyAuth;
use app\BaseController;
use think\facade\View;
use think\Request;

class Index
{
    /**本应用中间件
     * @param Request $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle(Request $request,\Closure $next){
//        echo 'haha';exit;
//        $project = getProject();
////        echo $project;exit;
//        session('project',$project);
//        cookie('project',$project);
//        setcookie('project',$project);
//        View::assign('project',$project);
//        echo request()->controller();
//        exit;
        if($request->controller()=='Index'){
            return $next($request);
        }
        if($request->isAjax()){
            if(!MyAuth::AuthYanZhen($request)){
                echo '权限不足';
            }
        }else{
            $bool = MyAuth::AuthYanZhen($request);
            if(!$bool){
                echo '权限不足';
            }
        }
        return $next($request);
    }
}